package com.net.controller;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import com.net.controller.model.ResponseModel;
import com.net.controller.vo.ListPageParam;
import com.net.service.vo.ServiceCode;
import com.net.util.ResponseEntityHelper;
import com.net.annotaion.ApiLog;
import com.net.model.Pack;
import com.net.model.Page;
import com.net.model.PageData;
import com.net.model.User;
import com.net.service.pack.PackageService;

@Controller
@RequestMapping(value = "/net/detect")
public class PackageApi extends SuperController {
	PackageService packageService;

	@Resource(name = "packageService")
	public void setPackageService(PackageService packageService) {
		this.packageService = packageService;
	}


	@ApiLog
	@RequestMapping(value = "/pack/tolistpage")
	public ModelAndView listPage(HttpServletRequest request) {
		ModelAndView mv = new ModelAndView();
		
		mv.setViewName("pack/package_list");
		return mv;
	}

	
	@ApiLog
	@RequestMapping(value = "/pack/listpage", method = RequestMethod.POST)
	public ResponseEntity<ResponseModel> listPage(@RequestBody ListPageParam listPageParam, HttpServletRequest request) {
		session = request.getSession();
		User user = (User) session.getAttribute("user");
		Page page = listPageParam.getPage();
		PageData pd = new PageData();
		page.setPd(pd);
		List<Pack> packageList = packageService.listPagePackage(page);
		listPageParam.setPage(page);
		listPageParam.setObjects(packageList);
		return ResponseEntityHelper.createResponse(ServiceCode.SUCCESS, "获取成功！",listPageParam);
	}
}
